<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="utf-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1">
    <!-- The above 3 meta tags *must* come first in the head; any other head content must come *after* these tags -->
    <meta name="description" content="">
    <meta name="author" content="">

    <title>mall</title>
    <!--导入依赖-->
    <link rel="stylesheet" href="../bootstrap/css/bootstrap.min.css">
    <link rel="stylesheet" href="../my/css/back.css">
    <script type="text/javascript" src="../js/jquery-3.6.0.min.js"></script>
    <script type="text/javascript" src="../bootstrap/js/bootstrap.min.js"></script>
    <script type="text/javascript" src="../js/vue.js"></script>
    <script type="text/javascript" src="../js/axios.min.js"></script>


</head>

<body>

<div>
    <!--导航栏-->
    <div>
        <nav class="navbar navbar-inverse navbar-fixed-top">
            <div class="container-fluid">
                <div class="navbar-header">
                    <button type="button" class="navbar-toggle collapsed" data-toggle="collapse" data-target="#navbar" aria-expanded="false" aria-controls="navbar">
                        <span class="sr-only">Toggle navigation</span>
                        <span class="icon-bar"></span>
                        <span class="icon-bar"></span>
                        <span class="icon-bar"></span>
                    </button>
                    <a class="navbar-brand" style="margin-left: 25px" href="#">白大师后台管理系统</a>
                </div>
                <div id="navbar" class="navbar-collapse collapse">
                    <ul class="nav navbar-nav navbar-right">
                        <li><a href="#">搜 索</a></li>
                        <li><a href="#">欢迎您：admin</a></li>
                        <li><a href="#">退出登录</a></li>
                    </ul>
                    <form class="navbar-form navbar-right">
                        <input type="text" class="form-control" placeholder="Search...">
                    </form>
                </div>
            </div>
        </nav>
    </div>
    <!--主体部分-->
    <div>
        <div class="container-fluid">
            <div class="row">
                <div class=" col-md-2 ">
                    <div class="sidebar">
                        <ul class="nav nav-sidebar nav-center">
                            <li>
                                <img src="../image/cat.png" width="150px" height="150px" class="img-circle">
                            </li>
                        </ul>
                        <ul class="nav nav-sidebar nav-center">
                            <li><a href="index.html">商品管理</a></li>
                            <li><a href="category.html" class="bg-primary">类别管理</a></li>
                            <li><a href="order.html">订单管理</a></li>
                            <li><a href="user.html">用户管理</a></li>
                            <li><a href="">通知公告</a></li>
                            <li><a href="">我的账户</a></li>
                        </ul>
                    </div>
                </div>
                <div class="col-md-8 main" id="categoryApp">
                    <h2 class="sub-header">分类管理</h2>
                    <button type="button" class="btn btn-success" id="addButton">新增分类</button>
                    <div class="table-responsive">
                        <table class="table myTable">
                            <thead>
                            <tr>
                                <th>序号</th>
                                <th>分类名称</th>
                                <th>操作</th>
                            </tr>
                            </thead>
                            <tbody>
                            <tr v-for="(category,index) in categories">
                                <td v-text="index+1">商品名字</td>
                                <td v-text="category.catName">商品介绍</td>
                                <td>
                                    <button type="button" class="btn btn-info" id="'updateButton'+category.id" @click="getInfo(category.id)">修改</button>
                                    <button type="button" class="btn btn-warning" @click="deleteCategory(category.id,index)">删除</button>
                                </td>
                            </tr>
                            </tbody>
                        </table>
                    </div>
                    <!--新增弹窗-->
                    <div class="modal fade" id="myModalAdd" tabindex="-1" role="dialog" aria-labelledby="myModalLabel">
                        <div class="modal-dialog" role="document">
                            <div class="modal-content">
                                <div class="modal-header">
                                    <button type="button" class="close" data-dismiss="modal" aria-label="Close"><span aria-hidden="true">&times;</span></button>
                                    <h4 class="modal-title">新增分类</h4>
                                </div>
                                <div class="modal-body">
                                    <div class="form-group">
                                        <label for="categoryName">分类名称</label>
                                        <input type="text" name="categoryName" class="form-control" id="categoryName" placeholder="分类名称">
                                    </div>
                                </div>
                                <div class="modal-footer">
                                    <button type="button"  class="btn btn-primary" data-dismiss="modal" @click.prevent="addCategory">
                                        <span class="glyphicon glyphicon-floppy-disk" aria-hidden="true"></span>
                                        确认新增
                                    </button>
                                </div>
                            </div>
                        </div>
                    </div>

                    <!--修改弹窗-->
                    <div class="modal fade" id="myModalUpdate" tabindex="-1" role="dialog" aria-labelledby="myModalLabel2">
                        <div class="modal-dialog" role="document">
                            <div class="modal-content">
                                <div class="modal-header">
                                    <button type="button" class="close" data-dismiss="modal" aria-label="Close"><span aria-hidden="true">&times;</span></button>
                                    <h4 class="modal-title" >修改分类</h4>
                                </div>
                                <div class="modal-body">
                                    <div class="form-group">
                                        <label for="categoryName">分类名称</label>
                                        <input type="text" name="categoryName" class="form-control" id="UpdateCategoryName" placeholder="分类名称">
                                    </div>
                                </div>
                                <div class="modal-footer">
                                    <button type="button"  class="btn btn-primary" data-dismiss="modal" @click.prevent="updateCategory"><span class="glyphicon glyphicon-floppy-disk" aria-hidden="true"></span>确认修改</button>
                                </div>
                            </div>
                        </div>
                    </div>
                </div>



            </div>
        </div>
    </div>

</div>

</body>
<script src="../my/js/back-category.js"></script>
<script>
    $("#addButton").click(function () {
        $("#myModalLabel").text("新增");
        $("#myModalAdd").modal();
    });

</script>
</html>
